package com.ntes.provider3.controller;

import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by june on 2017/5/28.
 */
@RestController
public class DemoController3 {
    @Value("${server.port}")
    int port;

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/getString")
    public String getString(String name) {
        String str = restTemplate.getForObject("http://SERVICE-DEMO/getUser?name=" + name, String.class);
        System.out.println(str);
        str = "provider3 at port " + port + ":" + name + " " + new Date();
        return str;
    }
}
